// noinspection JSUnusedGlobalSymbols
/**
 * 循环供应
 * @author 冰凝
 * @date 2022-11-04 11:47:46
 **/
export class LoopSupply<E = any> {
    private readonly arr: Array<E>
    private index: number = -1

    constructor(arr: Array<E>) {
        this.arr = arr
    }

    public next(): E {
        this.index++
        if (this.index >= this.arr.length) {
            this.index = 0
        }
        return this.arr[this.index]!
    }
}
